
#ifndef HAL_FLASH_H
#define HAL_FLASH_H

#include "hal_types.h"
#include "flash_lld.h"

#define CFLASH_START_ADDR	 (0x00000000u)
#define CFLASH_END_ADDR		 (0x00080000u)
#define CFLASH_SIZE			 (0x00080000u)
#define CFLASH_PAGE_NUM		 (64u)

#define PFLASH_START_ADDR	 (0x00800000u)
#define PFLASH_END_ADDR		 (0x00810000u)
#define PFLASH_SIZE			 (0x00010000u)
#define PFLASH_PAGE_NUM		 (8u)

typedef enum
{
	FLASH_SAME = 0,
	FLASH_DIFFERENT = 1
}flash_compare_en;

typedef enum
{
	FLASH_DTC = 0,
	FLASH_TEST = 1,
	FLASH_TEST2 = 2,
	FLASH_NUM
}flash_index_en;

typedef struct
{
	uint32_t tgt_addr;
	uint32_t len;
}flash_st;

typedef struct
{
	uint32_t flash_lsl;
	uint32_t flash_startaddr;
	uint32_t flash_size;
}flash_sector_st;

result_en hal_pfls_init(void);
result_en hal_pfls_erase(flash_index_en index ,uint32_t len);
result_en hal_pfls_read(flash_index_en index ,uint8_t * buff ,uint32_t len);
result_en hal_pfls_erase_write(flash_index_en index ,const uint8_t *buff ,uint32_t erase_len);
result_en hal_pfls_write(flash_index_en index ,const uint8_t *buff ,uint32_t len);
flash_compare_en hal_pfls_compare(flash_index_en index ,const uint8_t *buff ,uint32_t len);
result_en hal_pfls_blank_check(flash_index_en index ,uint32_t len);

result_en hal_cfls_init(void);
result_en hal_cfls_erase(flash_index_en index ,uint32_t len);
result_en hal_cfls_read(flash_index_en index ,uint8_t *buff ,uint32_t len);
result_en hal_cfls_rease_write(flash_index_en index ,const uint8_t *buff ,uint32_t erase_len);
result_en hal_cfls_write(flash_index_en index ,const uint8_t *buff , uint32_t len);
flash_compare_en hal_cfls_compare(flash_index_en index ,const uint8_t *buff ,uint32_t len);
result_en hal_cfls_blank_check(flash_index_en index ,uint32_t len);

#endif 
